<%@include file="/header.jsp"%>
<%@ page language="java" contentType="text/html"
    import="java.sql.*, javax.sql.*, javax.naming.*"  
 %>

<jsp:useBean id="dao" class="domainLogic.User" scope="session"/>
<jsp:useBean id="db" class="dataGateway.UserTable" scope="session"/>

<%
	int a = db.userExist(dao.getUsername());
	if(a == 0)  //Not Exist
	{
		if(db.insertMember(dao) == true)
		{
			out.println(common.JspUtil.makeErrorMsg(dao.getUsername()+", joined successfuly!", 
					common.JspUtil.URL_CONTENT_PAGE+"/login/login.jsp"));
		}
		else
		{
			out.println(common.JspUtil.makeErrorMsg("Error occurred while registering. Try again!", 
					common.JspUtil.URL_CONTENT_PAGE+"/member/addMember.jsp"));
		}
	}
	else
	{
		out.println(common.JspUtil.makeErrorMsg("username exists, try again!", 
				common.JspUtil.URL_CONTENT_PAGE+"/member/addMember.jsp"));
	}
%>
